/**
 * $Id$ Copyright 2009-2012 Oak Pacific Interactive. All rights reserved.
 */
package com.shuqi.model.parse.parser;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import com.shuqi.model.parse.HandlerBase;

/**
 * @author liyizhe 手机、邮箱注册解析
 */
public class AccountRegisterParser extends HandlerBase {

    private AccountRegisterParserInfo info;

    @Override
    public void startDocument() throws SAXException {
        super.startDocument();
        info = new AccountRegisterParserInfo();
    }

    @Override
    public void startElement(String uri, String localName, String name, Attributes attrs)
            throws SAXException {
        if (localName.equals("serverinfo")) {
            try {
                info.resultCode = isNull(attrs, "state");
            } catch (Exception e) {
                e.printStackTrace();
            }
            info.message = isNull(attrs, "message");
        } else if (localName.equals("UserInfo")) {
            try {
                info.gender = isNull(attrs, "gender");
            } catch (Exception e) {
                e.printStackTrace();
            }
            info.uid = isNull(attrs, "userId");
            info.nickName = isNull(attrs, "nickName");
            info.session = isNull(attrs, "session");
        }
    }

    @Override
    public AccountRegisterParserInfo getParsedData() {
        return info;
    }

    public static class AccountRegisterParserInfo {

        public String resultCode;

        public String message;

        public String uid;

        public String nickName;

        public String gender;

        public String session;
    }

}
